<?php
// A repository for common FoxyBack PHP functions.

// Format a message based on the requested template.
function formatMessage($message, $tpl) {
	global $modx;
	$message_chunk = $modx->getChunk($tpl);
	$message_output = preg_replace("/\[\+message\+\]/", $message, $message_chunk);
	return $message_output;
}

// Build a url-encoded string for use in a url based on an associative array.
function genUrlString($value_array=array()) {
	$parameters = array();

	foreach ($value_array as $key => $value)
		$parameters[] = $key.'=' . urlencode($value);

	return join('&', $parameters);
}

?>
